package com.ygy.jxc.controller;


import com.ygy.jxc.model.XtmdDept;
import com.ygy.jxc.service.XtDeptService;
import com.ygy.jxc.util.commonPage;
import com.ygy.jxc.util.commonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * 基础信息管理模块 -部门资料是调用系统管理中的部门，且只有查询 操作-------
 *  也可以不需要这个controller 使用系统管理的部门
 */

@Controller
@Api(tags = "JcDeptController" , description = "jc-3部门表")
@Tag(name = "JcDeptController", description = "基础信息管理-部门")
@RequestMapping("/jcDept")
public class JcDeptController {

@Autowired
    private XtDeptService deptService;


    @ApiOperation("获取所有部门")
    @RequestMapping(value = "/listAll", method = RequestMethod.GET)
    @ResponseBody
    public commonResult<List<XtmdDept>> listAll() {
        List<XtmdDept> customerList = deptService.list();
        return commonResult.success(customerList);
    }

    @ApiOperation("根据部门名或 地区获取部门")
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    @ResponseBody
    public commonResult<commonPage<XtmdDept>> list(@RequestParam(value = "keyword", required = false) String keyword,
                                                   @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                                   @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        List<XtmdDept> customerList = deptService.list(keyword, pageSize, pageNum);
        return commonResult.success(commonPage.restPage(customerList));
    }



}
